<template>
	<view>
		<view class="form-group">
			<view class="form-item">
				<label>旧密码</label>
				<view>
					<input type="password" placeholder="请输入旧密码" v-model="form.old_pwd"/>
				</view>
			</view>
			<view class="form-item">
				<label>新密码</label>
				<view>
					<input type="password" placeholder="请输入新密码" v-model="form.pwd"/>
				</view>
			</view>
			<view class="form-item">
				<label>确认密码</label>
				<view>
					<input type="password" placeholder="请确认新密码" v-model="form.repwd"/>
				</view>
			</view>
			<view class="form-item">
				<button @tap="submit">立即修改</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				form:{
					old_pwd : '',
					pwd:'',
					repwd:''
				}
			}
		},
		onLoad() {
		},
		methods:{
			submit(){
				if(!this.form.old_pwd)return this.toasts('请输入旧密码');
				if(!this.form.pwd)return this.toasts('请输入新密码');
				if(!this.form.repwd)return this.toasts('请确认新密码');
				if(this.form.pwd != this.form.repwd)return this.toasts('两次输入的密码不正确');
				this.ajax('user/editpwd',{
					data:this.form,
					success:(res) => {
						res = res.data;
						this.toasts(res.info);
						if(res.status) {
							uni.reLaunch({
								url:"../login/index"
							})
						}
					}
				});
			}
		}
	}
</script>

<style>
	.nav{height: 200upx;background: #409EFF;line-height: 200upx;font-size: 30upx;text-align: center;color:#FFFFFF}
	.nav text{font-size: 50upx;}
	.form-group{background: #FFFFFF;padding:20upx 0;}
	.form-item {width: calc(100% - 40upx);margin:20upx;overflow: hidden;line-height: 60upx;font-size: 35upx;}
	.form-item label,.form-item view{float:left;width:160upx;}
	.form-item view{width: calc(100% - 170upx);margin-left: 10upx;}
	.form-item input{font-size: 35upx;height:60upx;}
	.form-item button{height:80upx;line-height: 80upx;background: #409EFF;color:#FFFFFF;border:none;margin-top: 40upx;}
</style>
